import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { GoodsSpecValVO, GoodsSpecValForm, GoodsSpecValQuery } from '@/api/mall/goodsSpecVal/types';

/**
 * 查询商品规格列表
 * @param query
 * @returns {*}
 */

export const listGoodsSpecVal = (query?: GoodsSpecValQuery): AxiosPromise<GoodsSpecValVO[]> => {
  return request({
    url: '/mall/goodsSpecVal/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询商品规格详细
 * @param id
 */
export const getGoodsSpecVal = (id: string | number): AxiosPromise<GoodsSpecValVO> => {
  return request({
    url: '/mall/goodsSpecVal/' + id,
    method: 'get'
  });
};

/**
 * 新增商品规格
 * @param data
 */
export const addGoodsSpecVal = (data: GoodsSpecValForm) => {
  return request({
    url: '/mall/goodsSpecVal',
    method: 'post',
    data: data
  });
};

/**
 * 修改商品规格
 * @param data
 */
export const updateGoodsSpecVal = (data: GoodsSpecValForm) => {
  return request({
    url: '/mall/goodsSpecVal',
    method: 'put',
    data: data
  });
};

/**
 * 删除商品规格
 * @param id
 */
export const delGoodsSpecVal = (id: string | number | Array<string | number>) => {
  return request({
    url: '/mall/goodsSpecVal/' + id,
    method: 'delete'
  });
};
